﻿using System.IO;
using UnityEditor;
using UnityEngine;
using System.Collections;

public class MethodTools
{
	[MenuItem("Coser/Tools/Delete All PlayerPrefs")]
	public static void DeleteAllPlayerPrefs()
	{
		PlayerPrefs.DeleteAll();
		Debug.Log("Delete PlayerPrefs SUCCESS!");
	}


	[MenuItem("Coser/Tools/Delete All Bundles Data")]
	public static void DeleteAllPersistentData()
	{
		Directory.Delete(Application.persistentDataPath, true);
		Debug.Log("Delete Data SUCCESS!");
	}

	[MenuItem("Coser/Audio Tools/Batch Import Autio")]
	public static void ChangeAudioImportSetting()
	{
		var selections = Selection.objects;
		foreach (var selection in selections)
		{
			var audio = selection as AudioClip;
			if (audio)
			{
				var path = AssetDatabase.GetAssetPath(audio);
				var ai = AssetImporter.GetAtPath(path) as AudioImporter;
				if (ai)
				{
					ai.threeD = false;
                    ai.defaultSampleSettings = new AudioImporterSampleSettings()
                    {
                        loadType = AudioClipLoadType.CompressedInMemory,
                        sampleRateSetting = AudioSampleRateSetting.OptimizeSampleRate
                    };
                    
					AssetDatabase.ImportAsset(path, ImportAssetOptions.ForceUpdate);
				}

			}
		}
	}
}
